<html>
<head>
<title>ThinMVC Documentation: How it Works</title>
</head>
<body>
    <h3>How ThinMVC Works</h3>
      <p>The web application is set up as a PHP object library--a directory structure
        that contains regular PHP objects, like:</p>
      <p>/site/news/news.php<br>
        /site/login/login.php</p>
      <p>Along with the regular objects in the directory there are also controller
        objects that subclass ThinMVC_Controller:</p>
      <p>/site/news/newsController.php<br>
        /site/login/loginController.php</p>
      <p>Each request for a page is managed by a controller. The URL of the request
        maps to the directory name and a function inside the controller object,
        like this:</p>
      <p>This request: http://the.site.com/site/news/shownews<br>
        Loads the object /site/news/newsController.php and runs the &quot;shownews&quot;
        function</p>
      <p>The controller performs the logic and decides what should be viewed.
        To &quot;view&quot; something, it simply includes a php page in regular
        PHP fashion. The pages are stored inside the directory structure, too:</p>
      <p> /site/news/pages/list.php<br>
        /site/news/pages/article.php</p>
      <p> /site/login/pages/login.php<br>
        /site/login/pages/login_result.php<br>
        /site/login/pages/forgot_password.php</p>
			<p>So the full set of files and folders in a "news" setup might be:</p>
      <p>/site/news/news.php - object<br>
        /site/news/newsController.php - controller<br>
        /site/news/pages/list.php - view<br>
        /site/news/pages/article.php - view</p>
      <h3>Nesting & Templates</h3>
      <p>The controllers can chain together to form a page so that you can wrap
        templates around content. Like this:</p>
      <p>Someone goes to URL: http://site.com/home/company</p>
      <p>This would be handled by the top level controller under "home" (/home/homeController.php), which would call $this->call_next() at some point. This would pass control on to the next controller down (class <i>home_companyController</i> inside "/home/company/home_companyController.php").
      <p>This way &quot;homeController.php&quot; can build the header and the
        footer of the page, then pass control on to the pages that will build the content.
         You can chain as many of these together as you like.
        It can also be done from within pages. The page itself can say:</p>
      <p>&lt;h2&gt;HEADER&lt;/h2&gt;<br>
        &lt;?php $this-&gt;callNext(); ?&gt;<br>
        &lt;div&gt;this is the footer&lt;/div&gt;</p>
      <p>This allows you to easily wrap all of the pages into
        templates. </p>
<h3>HTML</h3>
<p>To accomodate this nesting function, every "view" can contain an HTML header and footer, and ThinMVC will remove them so that there is only one in the final display. It will also:</p>
<ul>
<li>Filter out all "title" tags except the final one, making the page title the one on the lowest possible page in the heirarchy.</li>
<li>Include all other header content (CSS, JavaScript, etc) in the final header that is rendered.</li>
<li>Remove everything from the BODY tag. It just gets too messy if you allow things like <i>"bgcolor=#000000"</i> in there. Just use CSS for your design and use JavaScript (<i>window.onload</i> or <i>document.addEventListener('load'))</i> to trigger JavaScript.</li>
</ul>

</body>
</html>
